package com.demo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class TestInvocationHandler implements InvocationHandler {

	private Object obj;

	public TestInvocationHandler(Object obj) {
		super();
		this.obj = obj;
	}

	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}

	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		String methodName = method.getName();
		System.out.println(methodName + "开始时间:" + System.currentTimeMillis());
		Object result = method.invoke(obj, args);
		System.out.println(methodName + "结束时间:" + System.currentTimeMillis());
		return result;
	}

}
